import { createServer } from 'http'
import { Server } from 'socket.io'
import createBlindBoxServer from './blind_box'
import createXycServer from './xyc'

export default function runServer() {
    const server = createServer()
    const socketServer = new Server(server)

    createXycServer(socketServer, server)
    createBlindBoxServer(socketServer, server)

    server.on('close', () => process.exit())

    server.listen(13000, () => {
        console.log('server running')
    })
}

if (require.main === module) {
    runServer()
}
